package jdbc;

import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.Statement;
import java.util.Scanner;

public class UpdateUserDemo {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入用户名：");
        String username = sc.next();
        System.out.println("请输入新密码：");
        String password = sc.next();
        System.out.println("请输入新昵称：");
        String nickname = sc.next();


        Connection connection = DBUtil.getConnection();
        Statement statement = connection.createStatement();
        String sql = "update userinfo set password = '"+password+"',nickname = '"+nickname+"' where username = '"+username+"'";

        int num = statement.executeUpdate(sql);
        System.out.println(num>0?"修改成功！":"用户名不存在！！！");

        connection.close();
    }
}
